﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PagedList<App.Models.vi_ServiceDetail>>" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc"%>
    <script type="text/javascript">
        function doDiscount(obj) {
            var uprice = obj.unitprice;
            var qty = obj.value;
            var fees = uprice * qty;
            var id = obj.id.substring(2);
            //异步提交更新
            $.get('/CheckoutService/Discount?serviceNo=' + id + "&qty=" + qty + "&fee=" + fees,
                function (data) {
                    $("#SF" + id).html(data);       //提交成功更新费用
                });
        }
    </script>
    <div id="dvList" class="list">
    <table width="100%" cellpadding="0"cellspacing="1" border="0">
        <tr>             
            <th>死者编号</th>
            <th>姓名</th>
            <th>服务项目</th>
            <th>计量单位</th>
            <th>单价</th>
            <th>数量</th>
            <th>优惠后数量</th>
            <th>费用</th>
            <th>支付状态</th>
            <th>业务员</th>
        </tr>

    <% if (Model != null && Model.Count > 0) foreach (var item in Model){ %>    
        <tr>                        
            <td><%: item.DeadNO %></td>
            <td><%: item.DeadName %></td>
            <td><%: item.ItemName %></td>
            <td><%: item.Unit %></td>
            <td><%: String.Format("{0:F}", item.Price!=null?item.Price : item.ServiceFee/item.ServiceCount) %></td>
            <td><%: item.ServiceCountBak %></td>
            <td><input type="text" value="<%: item.ServiceCount %>" 
                id="SC<%: item.ServiceNo %>" name="ServiceCount"  style="width:40px" 
                unitprice="<%:item.Price!=null?item.Price : item.ServiceFee/item.ServiceCount %>" 
                onchange="doDiscount(this)" 
                <% if(item.PayStatus){ %> disabled="disabled" <%} %> />
            </td>
            <td id="SF<%: item.ServiceNo %>"><%: String.Format("{0:F}", item.ServiceFee) %></td>            
            <td><input type="checkbox" id="PS<%: item.ServiceNo %>" name="chkPayStatus" 
                    subtotals="<%:item.ServiceFee%>" value="<%: item.ServiceNo %>" 
                    <% if(item.PayStatus){ %> checked="checked" disabled="disabled" <%} %>/>
            </td>
            <td><%: item.Salesman %></td>            
        </tr>    
    <% }
       else { 
    %>
        <tr><td colspan="10"> 没有任何记录！</td></tr>
    <%
       } %>

    </table>
    <%=Html.AjaxPager(Model, new PagerOptions() { 
        CssClass = "page", 
        PageIndexParameterName = "id", 
        ShowMorePagerItems = false, 
        AlwaysShowFirstLastPageNumber = true, 
        ShowNumericPagerItems = true,
        NumericPagerItemCount = App.Models.Utils.PAGE_SIZE,        
        PageIndexOutOfRangeErrorMessage = "索引页超出范围",
        FirstPageText = "<img src='../../images/main_54.gif' />",
        PrevPageText = "<img src='../../images/main_56.gif' />",
        NextPageText = "<img src='../../images/main_58.gif' />",
        LastPageText = "<img src='../../images/main_60.gif' />",        
        GoButtonText = "转",     
        HorizontalAlign = "right",   
        ShowPageIndexBox = true, 
        PageIndexBoxWrapperFormatString = "转到{0}" },
                                 new AjaxOptions() { UpdateTargetId = "dvList", HttpMethod="GET" })%>
   
    </div>

